<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of i-studio_mail
 *
 * @author yxw
 */
class istudio_mail {
//put your code here
    public static function mail($body,$address,$toname){
        include_once(dirname(__FILE__).'/class.phpmailer.php');
        include_once(APPROOT.'/web.config.php');
        //echo 'ssssssssss';
        $mail             = new PHPMailer();

        //$body             = "你好你的密码是";//邮件内容 可以是html

        $mail->IsSMTP(); // telling the class to use SMTP
        $mail->CharSet = "UTF-8"; 
        //$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                                   // 1 = errors and messages
                                                   // 2 = messages only
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->Host       = mailHost; // sets the SMTP server
        $mail->Port       = mailPort;                    // set the SMTP port for the GMAIL server
        $mail->Username   = mailUsername; // SMTP account username
        $mail->Password   = mailPassword;        // SMTP account password
        $mail->SMTPSecure = "ssl";//gmail 使用ssl
        $mail->SetFrom(mailFormmail, mailFormname);

        //$mail->AddReplyTo("han@dacbj.com.cn","First Last");//增加回复标签

        $mail->Subject    = mailSubject;

        $mail->AltBody    = $body; // 当邮件不支持html时用这个值代替 optional, comment out and test

        $mail->MsgHTML($body);
        
        //AddBCC 增加密送
        //
        //$address = "hxlhxl.xl@gmail.com";
        $mail->AddAddress($address, $toname);//增加收件人

        //$mail->AddAttachment("images/phpmailer.gif");      // 增加附件
        //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
        //echo "Mailer Error: " . $mail->ErrorInfo;

        /*if(!$mail->Send()) {
          return false;
        } else {
          return true;
          //echo "Message sent!";
        }*/
        return $mail->Send();
    }
}
?>
